package com.example.castday1.test;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.castday1.bean.UserA;
import com.example.castday1.mapper.UserMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.List;

/**
 * @Author : 徐闯 mpcast
 * @Date : 2021-05-23 20:05:09
 * @Description : 实体作为条件构造器的参数
 **/
@RunWith(SpringRunner.class)
@SpringBootTest
public class E_TestEntityParam {
    @Autowired
    private UserMapper userMapper;
    @Test
    public void test(){
        UserA userA = new UserA();
        userA.setUserId(10001L);
        userA.setEmail("xxx@xxx.com");
        userA.setAge(20);
        QueryWrapper<UserA> queryWrapper = new QueryWrapper(userA);
        queryWrapper.like("name","z");
        List<UserA> userAList = userMapper.selectList(queryWrapper);
        userAList.forEach(System.out::println);
    }
}
